export const __isEmpty = (value: any) => {
  return value === undefined || value === null || value === "";
};

export const __formatNumber = (num: number): string => {
  if (num < 1000) {
    return `${num}`;
  }

  let divisor: number;
  let suffix: string;

  if (num >= 1000 && num <= 9999) {
    divisor = 1000.0;
    suffix = "k";
  } else if (num >= 10000 && num <= 9999999) {
    divisor = 10000.0;
    suffix = "w";
  } else {
    divisor = 10000000.0;
    suffix = "kw";
  }

  const formattedCount = num / divisor;
  const roundedCount = Math.floor(formattedCount * 10) / 10;

  if (roundedCount % 1 !== 0) {
    return `${roundedCount.toFixed(1)}${suffix}`;
  } else {
    return `${Math.floor(roundedCount)}${suffix}`;
  }
};

export const __getThumbUrl = (url: string, size: number): string => {
  if (__isEmpty(url)) {
    return "";
  }

  if (url.includes("metatube.pro") || url.includes("ideaflow.pro")) {
    return `${url}?imageView2/3/w/${size}/h/${size}`;
  } else {
    return url;
  }
};
